<admintpl file="header" />
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="javascript:;">试题管理</a></li>
			<li><a href="{:U('Questions/add',array('term'=>empty($term['term_id'])?'':$term['term_id']))}" target="_self">添加试题</a></li>
			<li><a href="{:U('Questions/import')}" target="_self">批量导入</a></li>
			<li><a href="{:U('Questions/recyclebin',array('term'=>empty($term['term_id'])?'':$term['term_id']))}" target="_self">试题回收站</a></li>
		</ul>
		<form class="well form-search" method="post" action="{:U('Questions/index')}">
			分类： 
			<select name="term_id" style="width: 120px;">
				<option value='0'>全部</option>{$taxonomys}
			</select> &nbsp;&nbsp;
			题型： 
			<select name="type_id" style="width: 120px;">
				<option value='0'>全部</option>
				<foreach name="question_types" item="vo">
				<option value="{$key}" <eq name="key" value="$type_id">selected</eq>>{$vo}</option>
				</foreach>
			</select> &nbsp;&nbsp;
			难度： 
			<select name="ques_level" style="width: 120px;">
			<option value="0" <eq name="ques_level" value="0">selected</eq>>全部</option>	
			<foreach name="question_level" item="vo">					
			<option value="{$key}" <eq name="key" value="$ques_level">selected</eq>>{$vo}</option>
			</foreach>
			</select> &nbsp;&nbsp;
			试题ID： 
			<input type="text" name="id" style="width: 130px;" value="{$id}" placeholder="请输入试题ID">
			题干：
			<input type="text" name="keyword" style="width: 130px;" value="{$keyword}" placeholder="请输入题干关键字">
			<input type="submit" class="btn btn-primary" value="搜索" />
			<a class="btn btn-danger" href="{:U('Questions/index')}">清空</a>
		</form>
		<form class="js-ajax-form" action="" method="post">
			<div class="table-actions">
<!--				<notempty name="term">
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Questions/listorders')}">{:L('SORT')}</button>
				</notempty>
 				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Questions/check',array('check'=>1))}" data-subcheck="true">审核</button>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Questions/check',array('uncheck'=>1))}" data-subcheck="true">取消审核</button>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Questions/top',array('top'=>1))}" data-subcheck="true">置顶</button>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Questions/top',array('untop'=>1))}" data-subcheck="true">取消置顶</button>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Questions/recommend',array('recommend'=>1))}" data-subcheck="true">推荐</button>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Questions/recommend',array('unrecommend'=>1))}" data-subcheck="true">取消推荐</button>
				<notempty name="term">
					<button class="btn btn-primary btn-small js-articles-move" type="button">批量移动</button>
				</notempty>
				<button class="btn btn-primary btn-small js-articles-copy" type="button">批量复制</button> -->
				<button class="btn btn-danger btn-small js-ajax-submit" type="submit" data-action="{:U('Questions/delete')}" data-subcheck="true" data-msg="您确定删除吗？">{:L('DELETE')}</button>
			</div>
			<table class="table table-hover table-bordered table-list">
				<thead>
					<tr>
						<th width="15"><label><input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x"></label></th>
						<notempty name="term">
						<th width="50">排序</th>
						</notempty>
						<th width="30">ID</th>
						<th width="80">试题分类</th>
						<th width="50">题型</th>
						<th width="50">试题分数</th>
						<th width="160">题干描述</th>
						<th width="50">作者</th>
						<th width="90">发布时间</th>
						<th width="90">更新时间</th>
						<th width="30">状态</th>
						<th width="70">操作</th>
					</tr>
				</thead>
				<foreach name="posts" item="vo">
				<tr>
					<td><input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]" value="{$vo.id}" title="ID:{$vo.id}"></td>
					<notempty name="term">
					<td><input name="listorders[{$vo.tid}]" class="input input-order" type="text" size="5" value="{$vo.listorder}"></td>
					</notempty>
                    <td><b>{$vo.id}</b></td>
					<td>{$question_terms[$vo['ques_term']]}</td>
					<td>{$question_types[$vo['ques_type']]}</td>
					<td>{$vo.ques_score}</td>
					<td>
						<notempty name="term">
						<a href="{:leuu('admin/questions/index',array('id'=>$vo['id'],'cid'=>$term['term_id']))}" target="_blank">{$vo.ques_content}</a>
						<else/>
							{$vo.ques_content}
						</notempty>
					</td>
					<td>{$vo.user_nicename|default=$vo.user_login}</td>					
					<td>{:date('Y-m-d H:i',strtotime($vo['ques_date']))}</td>
					<td>{:date('Y-m-d H:i',strtotime($vo['ques_modified']))}</td>
					<td>
						<notempty name="vo.ques_status">
							<a data-toggle="tooltip" title="已停用"><i class="fa fa-close"></i></a>
							<else/>
							<a data-toggle="tooltip" title="已启用"><i class="fa fa-check"></i></a>
						</notempty>
					</td>
					<td>
						<a href="{:U('Questions/edit',array('id'=>$vo['id']))}">{:L('EDIT')}</a> | 
						<a href="{:U('Questions/delete',array('id'=>$vo['id']))}" class="js-ajax-delete">{:L('DELETE')}</a>
					</td>
				</tr>
				</foreach>
				<tfoot>
					<tr>
						<th><label><input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x"></label></th>
						<notempty name="term">
						<th>排序</th>
						</notempty>
						<th>ID</th>
						<th>试题分类</th>
						<th>题型</th>
						<th>试题分数</th>
						<th>题干描述</th>
						<th>作者</th>
						<th>发布时间</th>
						<th>更新时间</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</tfoot>
			</table>
			<div class="table-actions">
				<notempty name="term">
				<!-- <button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Questions/listorders')}">{:L('SORT')}</button>
				</notempty>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Questions/check',array('check'=>1))}" data-subcheck="true">审核</button>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Questions/check',array('uncheck'=>1))}" data-subcheck="true">取消审核</button>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Questions/top',array('top'=>1))}" data-subcheck="true">置顶</button>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Questions/top',array('untop'=>1))}" data-subcheck="true">取消置顶</button>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Questions/recommend',array('recommend'=>1))}" data-subcheck="true">推荐</button>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Questions/recommend',array('unrecommend'=>1))}" data-subcheck="true">取消推荐</button>
				<notempty name="term">
					<button class="btn btn-primary btn-small js-articles-move" type="button">批量移动</button>
				</notempty>
				<button class="btn btn-primary btn-small js-articles-copy" type="button">批量复制</button> -->
				<button class="btn btn-danger btn-small js-ajax-submit" type="submit" data-action="{:U('Questions/delete')}" data-subcheck="true" data-msg="你确定删除吗？">{:L('DELETE')}</button>
			</div>
			<div class="pagination">{$page}</div>
		</form>
	</div>
	<script src="__PUBLIC__/js/common.js"></script>
	<script>
		function refersh_window() {
			var refersh_time = getCookie('refersh_time');
			if (refersh_time == 1) {
				window.location = "{:U('Questions/index',$formget)}";
			}
		}
		setInterval(function() {
			refersh_window();
		}, 2000);
		$(function() {
			setCookie("refersh_time", 0);
			Wind.use('ajaxForm', 'artDialog', 'iframeTools', function() {
				//批量复制
				$('.js-articles-copy').click(function(e) {
					var ids=[];
					$("input[name='ids[]']").each(function() {
						if ($(this).is(':checked')) {
							ids.push($(this).val());
						}
					});
					
					if (ids.length == 0) {
						art.dialog.through({
							id : 'error',
							icon : 'error',
							content : '您没有勾选信息，无法进行操作！',
							cancelVal : '关闭',
							cancel : true
						});
						return false;
					}
					
					ids= ids.join(',');
					art.dialog.open("__ROOT__/index.php?g=portal&m=Questions&a=copy&ids="+ ids, {
						title : "批量复制",
						width : "300px"
					});
				});
				//批量移动
				$('.js-articles-move').click(function(e) {
					var ids=[];
					$("input[name='ids[]']").each(function() {
						if ($(this).is(':checked')) {
							ids.push($(this).val());
						}
					});
					
					if (ids.length == 0) {
						art.dialog.through({
							id : 'error',
							icon : 'error',
							content : '您没有勾选信息，无法进行操作！',
							cancelVal : '关闭',
							cancel : true
						});
						return false;
					}
					
					ids= ids.join(',');
					art.dialog.open("__ROOT__/index.php?g=portal&m=Questions&a=move&old_term_id={$term.term_id|default=0}&ids="+ ids, {
						title : "批量移动",
						width : "300px"
					});
				});
			});
		});
	</script>
</body>
</html>